#!/bin/sh

#
# This file is released under the terms of the Artistic License.
# Please see the file LICENSE, included in this package, for details.
#
# Copyright (C) 2002-2010 Mark Wong & Open Source Development Lab, Inc.
#

if [ "x${DBT5DBNAME}" = "x" ]; then
	echo "DBT5DBNAME not defined."
	exit 1
fi

while getopts "o:" opt; do
	case ${opt} in
	o)
		OUTPUT=${OPTARG}
		;;
	esac
done

if [ "x${OUTPUT}" = "x" ]; then
	echo "use -o and specify the backup file"
	exit 1;
fi

_test=`pg_dump ${DBT5DBNAME} --file=${OUTPUT} | grep OK`
if [ "x$_test" != "x" ]; then
	echo "backup failed: $_test"
	exit 1
fi

exit 0
